package com.crscd.kt.demo

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @since 2022-08-19 下午4:22
 */
class Person(val name: String, var age: Int = 0) {
    var children: MutableList<Person> = mutableListOf<Person>();
    init {
        println("name is $name, age is $age")
    }

    constructor(name: String, age: Int, person: Person) : this(name, age){
        person.children.add(this)
    }
}

fun main() {
    val person = Person("yuan")
    val parentPerson = Person("kang", 1, person)
    println(person)
    println(parentPerson)

    val jack = User(name = "Jack", age = 1)
    val olderJack = jack.copy(age = 2)
    val (name, age) = jack
    println("$name, $age years of age")
}